<%--
  Description: 
  User: wangguichun
  Date: 2018/4/11
  Time: 9:16
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>les9</title>
    <script src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>

    <script>
        function queryUser() {
            var id = $("#inputBox").val();

            $.ajax("${pageContext.request.contextPath}/les9_1",{
                data:{"userId":id},
                success:function (data) {
                    $("#id").text(id);
                    $("#name").text(data.user.username);

                    if (data.user.sex === 1){
                        $("#sex").text("男");
                    }else if (data.user.sex === 0) {
                        $("#sex").text("女");
                    }



                    $("#address").text(data.user.address);
                }
            })



        }



    </script>


</head>
<body>
今日内容：Ajax请求<br>

请输入你需要查询的ID：<input id="inputBox" type="text">
<input type="button" value="查询" onclick="queryUser();">
<hr>
<h1>ID:<span id="id"></span></h1>
<h1>姓名:<span id="name"></span></h1>
<h1>性别:<span id="sex"></span></h1>
<h1>地址:<span id="address"></span></h1>


</body>
</html>
